#include <iostream>
#include <cstdint>

struct MyStruct
{
	int a;	//4
	short b;//2 + 2
	int c;	//4
	short e;//2 + 2
};

class MyClass {
	//float data = 0.0;

	MyStruct mystruct;//16
	short a;	//2

public:
	MyClass() {}

public:
	void func() {}

public:
	//virtual void func1() {}
};

struct MyStruct1
{
	int* p;	//8
	int a;	//4
	short b;//2 + 2
	int c;	//4 + 4
};


class Base {
	int a;
public:
	virtual void f() { std::cout << a << "Base::f()" << std::endl; }
	virtual void g() { std::cout << "Base::g()" << std::endl; }
	virtual void h() { std::cout << "Base::h()" << std::endl; }
};

class Base1 : public Base {
public:
	virtual void x() { std::cout << "Base1::x()" << std::endl; }
	virtual void y() { std::cout << "Base1::y()" << std::endl; }
	virtual void z() { std::cout << "Base1::z()" << std::endl; }
};


using VoidFuncptr = void(*)();

int main() {
	std::cout << sizeof(MyStruct1) << std::endl;

	Base b;
	Base1 b1;

	Base* pb = &b;

	auto vptrb = (int64_t*)&b;
	std::cout << "vptr addr: " << vptrb << std::endl;
	std::cout << "vptr point to vtbl addr: " << (void*)*vptrb << std::endl;


	auto pvptrb = (int64_t*)*vptrb;
	std::cout << "vfunc addr: " << pvptrb << std::endl;
	std::cout << "vfunc point addr: " << (void*)*pvptrb << std::endl;

	VoidFuncptr callFunc = (VoidFuncptr)*pvptrb;
	callFunc();

	return 0;
}